<?php namespace Common\Model;
use Hdphp\Model\Model;
class Goods_order extends Model{
	//指定表名
	protected $table='goodsorder';
	//自动完成
	protected $auto=[
		['gotime','time','function',3,1]
	];
	//自动验证
	protected $validate=[
		
	];
	//添加订单
	public function store(){
		if(!$this->create()) return FALSE;
		$orderData=Q('post.orderData');
		$this->data['gonum']=Cart::getOrderId();
		$this->data['gototal']=$orderData['gototal'];
		$this->data['goallnum']=$orderData['goallnum'];
		$_SESSION['goid']=$this->add();
		return $_SESSION['goid'];
	}
	//补充完整订单
	public function edit(){
	    if(!$this->create()) return FALSE;
		$uaid=Q('post.shop_user_address_uaid');
		if(!$uaid) {
			$this->error='请选择收货地址';
			return FALSE;
		}
		return $this->save();
	}
	//支付完成
	public function pay(){
		$goid=$_SESSION['goid'];
		$this->where("goid={$goid}")->update(['goorder'=>1]);
		return TRUE;
	}
}
 ?>